/*从生词数据库中得到生词表并显示。
 * 内容包括：单词，最后复习时间，词义
 */

package cn.edu.nuc.ehelper;

import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.CursorAdapter;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import cn.edu.nuc.wordsbook.Constant;
import cn.edu.nuc.wordsbook.SQLiteOperationHelper;

public class WordsBookActivity extends ListActivity {

	private ListView listView;
	private SQLiteOperationHelper DBHelper = null;
	private Cursor cursor;
	private CursorAdapter cursorAdapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.wordsbook);
		WordsBookActivity.this.setTitle("生词本");

		DBHelper = new SQLiteOperationHelper(WordsBookActivity.this,
				Constant.DB_NAME, null, 1);
		cursor = DBHelper.query("milldate asc");
		startManagingCursor(cursor);

		listView = getListView();
		cursorAdapter = new SimpleCursorAdapter(WordsBookActivity.this,
				R.layout.wordsbooklist, cursor, new String[] { "english",
						"lastdate", "translation" }, new int[] {
						R.id.wordsItemId, R.id.timestampItemId,
						R.id.meaningItemId });
		listView.setAdapter(cursorAdapter);
	}

}
